//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.kx.hackathon.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Component;

@Component
public class JSONToolkit {
    private static ObjectMapper mapper;

    public JSONToolkit() {
    }

    private static void init() {
        if (mapper == null) {
            mapper = (ObjectMapper)SpringContextUtil.getBean(ObjectMapper.class);
        }

    }

    public static String stringify(Object obj) {
        init();

        try {
            return mapper.writeValueAsString(obj);
        } catch (JsonProcessingException var2) {
            var2.printStackTrace();
            return null;
        }
    }

    public static String prettyStringify(Object obj) {
        init();

        try {
            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
        } catch (JsonProcessingException var2) {
            var2.printStackTrace();
            return null;
        }
    }

    public static Object parse(String json, Class<?> clazz) throws JsonProcessingException {
        init();
        return mapper.readValue(json, clazz);
    }
}
